home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / GLOBMO~1.CLS < prev    next >
Text File  |  1997-06-14  |  3KB  |  92 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CGlobModFilter"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11.  
  12. Implements IFilter
  13.  
  14. Private sSource As String, sTarget As String
  15. Private fAttribute As Boolean, fName As Boolean
  16. Private sName As String
  17.  
  18. ' CPubPrivFilter-specific methods and properties
  19. Public Property Let Name(sNameA As String)
  20.     sName = sNameA
  21. End Property
  22. Public Property Get Name() As String
  23.     Name = sName
  24. End Property
  25.  
  26. Private Sub Class_Initialize()
  27.     fAttribute = True
  28. End Sub
  29.  
  30. ' IFilter implementation
  31. Private Property Let IFilter_Source(sSourceA As String)
  32.     sSource = sSourceA
  33. End Property
  34. Private Property Get IFilter_Source() As String
  35.     IFilter_Source = sSource
  36. End Property
  37.  
  38. Private Property Let IFilter_Target(sTargetA As String)
  39.     sTarget = sTargetA
  40. End Property
  41. Private Property Get IFilter_Target() As String
  42.     IFilter_Target = sTarget
  43. End Property
  44.  
  45. Private Function IFilter_Translate(sLineA As String, ByVal iLineA As Long) As EChunkAction
  46.     ' Translate most lines
  47.     IFilter_Translate = ecaTranslate
  48.     
  49.     If Not fName Then
  50.         ' Skip everything until we find VB_Name
  51.         fName = IsNameFound(sLineA)
  52.         If Not fName Then IFilter_Translate = ecaSkip
  53.     ElseIf fAttribute Then
  54.         ' Skip the remaining attributes
  55.         fAttribute = IsAttribute(sLineA)
  56.         If fAttribute Then IFilter_Translate = ecaSkip
  57.     End If
  58. End Function
  59.  
  60. Private Function IsNameFound(sLine As String) As Boolean
  61.     If sLine = sEmpty Then Exit Function
  62.     
  63.     ' Find VB_Name attribute and change it
  64.     Dim sSep As String
  65.     sSep = " " & sTab
  66.     If GetQToken(sLine, sSep) = "Attribute" Then
  67.         If GetQToken(sEmpty, sSep) = "VB_Name" Then
  68.             ' Use default standard name if standard name isn't already set
  69.             If sName = sEmpty Then
  70.                 ' Skip "="
  71.                 Call GetQToken(sEmpty, sSep)
  72.                 sName = GetQToken(sEmpty, sSep)
  73.                 If Left$(sName, 1) = "G" Then
  74.                     sName = "M" & Right$(sName, Len(sName) - 1)
  75.                 Else
  76.                     sName = "M" & sName
  77.                 End If
  78.             End If
  79.             sLine = "Attribute VB_Name = " & sQuote2 & sName & sQuote2
  80.             IsNameFound = True
  81.         End If
  82.     End If
  83. End Function
  84.  
  85. Private Function IsAttribute(sLine As String) As Boolean
  86.     If sLine = sEmpty Then Exit Function
  87.     
  88.     Dim sSep As String
  89.     sSep = "_"
  90.     IsAttribute = (GetQToken(sLine, sSep) = "Attribute VB")
  91. End Function
  92.